package com.giants.common.exception;

import java.util.ArrayList;
import java.util.List;

/**
 * @author vencent.lu
 *
 */
public abstract class GiantsException extends RuntimeException {

	private static final long serialVersionUID = -516478451762223581L;
	
	private String errorMessageKey;
	private List<Object> messageArgs;
		
	public abstract byte buildErrorCode();
	
	public GiantsException(String errorMessageKey) {
		super(errorMessageKey);
		this.errorMessageKey = errorMessageKey;
	}
		
	public GiantsException(String errorMessageKey,Object arg){
		super(errorMessageKey);
		this.errorMessageKey = errorMessageKey;
		this.messageArgs = new ArrayList<Object>();
		this.messageArgs.add(arg);
	}
	
	public GiantsException(String errorMessageKey,Object[] argArray){
		super(errorMessageKey);
		this.errorMessageKey = errorMessageKey;
		this.messageArgs =  new ArrayList<Object>();
		for(Object arg : argArray){
			this.messageArgs.add(arg);
		}
	}
	
	public String getErrorMessageKey() {
		return errorMessageKey;
	}

	public List<Object> getMessageArgs() {
		return messageArgs;
	}

	public void setErrorMessageKey(String errorMessageKey) {
		this.errorMessageKey = errorMessageKey;
	}

	public void setMessageArgs(List<Object> messageArgs) {
		this.messageArgs = messageArgs;
	}

}
